<?php if($products || $giftcards){ ?> 			
    <form id="cart" action="<?php echo str_replace('&', '&amp;', $action); ?>" method="post" enctype="multipart/form-data">
        <table class="viewshoppingbag" width="100%" cellspacing="0" cellpadding="0">
            <tr class="HeadTb">
                <td class="proImg"><span> Varebeskrivelse</span></td>
                <td class="proName"><span>&nbsp; </span></td>
                <td class="proFave"><span>Farve</span></td>
                <td class="proSize"><span>Størrelse</span>  </td>
                <td class="proNumber"> <span>Antal</span> </td>
                <td class="proPrice"> <span>Pris pr. stk</span> </td>
                <td class="proPriceTT"><span>Pris i alt</span></td>
                <td class="proDel"><span>&nbsp;</span></td>
            </tr><!--eachRowPro-->
            <tr class="space">
                <td colspan="8"></td>
            </tr><!--eachRowPro-->

            <?php foreach ($products as $product) { ?>
                <tr class="eachRowPro">
                    <td class="proImg">
                        <div class="boxThumb"><img src="<?php echo $product['thumb']; ?>" alt="" /></div>
                    </td>
                    <td class="proName">
                        <h2 class="proName"><a href="#"><?php echo $product['name']; ?></a></h2>
                        <p>
                            <?php
                                $max = count($product['option']);
                                if($max <= 0){
                                    $product_number = $product['product_number'] ? $product['product_number'] : '&nbsp;';
                                }elseif($max == 1){
                                    $product_number = $product['option'][0]['product_number'] ? $product['option'][0]['product_number'] : $product['product_number'];
                                }else{
                                    $product_number = $product['product_number'];
                                    foreach($product['option'] as $option_value){
                                        if($option_value['product_number']){
                                            $product_number = $option_value['product_number'];
                                        }
                                    }
                                }
                            ?>
                            Vare-nummer: <?php echo $product_number; ?>
                        </p>
                    </td>
                    <?php if($max == 1){ ?>
                        <td class="proFave"><span><?php echo $product['option'][0]['name']; ?></span></td>
                        <td class="proSize"><span><?php echo $product['option'][0]['value'];?></span>  </td>
                    <?php }elseif($max > 1){ ?>
                        <?php foreach($product['option'] as $option_value){ ?>
                            <td class="proFave"><span><?php echo $option_value['name'] ?></span></td>
                            <td class="proSize"><span><?php echo $option_value['value'];?></span>  </td>
                        <?php } ?>
                    <?php } ?>
                    <td class="proNumber">
                        <div class="wrapedit">
                            <input type="text" class="inputNumber" value="<?php echo $product['quantity']; ?>" name="quantity[<?php echo $product['key']; ?>]"/>
                            <a href="javascript:void(0)" class="cart_inc_qty" p_id="<?php echo $product['key'];?>"><span class="add">+</span></a>
                            <a href="javascript:void(0)" class="cart_dec_qty" p_id="<?php echo $product['key'];?>"><span class="sub">-</span></a>
                        </div>
                    </td>
                    <td class="proPrice"><span><?php echo $product['price'];?></span></td>
                    <td class="proPriceTT" ><span><?php echo $product['subtotals']?></span></td>
                    <td class="proDel" >
                        <a class="cart_delete_product" href="javascript:void(0);">
                            <input type="checkbox" style="display:none;" name="remove[<?php echo $product['key']; ?>]" />
                            <span><img src="catalog/view/theme/<?php echo $template; ?>/images/btnDel.jpg" alt="Delete"> </span>
                        </a>
                    </td>
                </tr><!--eachRowPro-->
            <?php } ?>

            <?php foreach ($giftcards as $giftcard) { ?>
                <tr class="eachRowPro">
                    <td class="proImg">
                        <div class="boxThumb"><img src="<?php echo $giftcard['thumb']; ?>" alt="<?php echo $giftcard['description']; ?>" /></div>
                    </td>
                    <td class="proName" colspan="3">
                        <h2 class="proName"><a href="#"><?php echo $giftcard['description']; ?></a></h2>
                    </td>
                    <td class="proNumber">
                        <div class="wrapedit">
                            <input type="text" class="inputNumber" value="1" name="giftcard[<?php echo $giftcard['key']; ?>]" disabled />
                        </div>
                    </td>
                    <td class="proPrice"><span><?php echo $giftcard['amount'];?></span></td>
                    <td class="proPriceTT"><span><?php echo $giftcard['amount'];?></span></td>
                    <td class="proDel" >
                        <a class="cart_delete_product" href="javascript:void(0);">
                            <input type="checkbox" style="display:none;" name="giftcard[]" value="<?php echo $giftcard['key']; ?>"/>
                            <span><img src="catalog/view/theme/<?php echo $template; ?>/images/btnDel.jpg" alt="Delete"> </span>
                        </a>
                    </td>
                </tr>
            <?php } ?>
        </table>

        <div class="wrapTotalPrice clearfix">
           <span class="lbTotal">TOTAL:</span> <span class="totalPrice"><?php echo $totals; ?></span>
        </div><!--wrapTotalPrice-->
        <div class="wrap-button">
            <a class="btn btnViewcart" href="<?php echo $view;?>">SE VArekurv</a>
            <a class="btn btntoPayment" href="<?php echo $checkout; ?>">Gå til kassen </a>
        </div><!--wrap-button -->
    </form>
<?php }else{ ?>
    <h4 style="padding: 30px; text-align:center; text-transform:none;">Din indkøbskurv er tom!</h4>
<?php }?>

<script type="text/javascript">
    //Delete item in cart
    jQuery('a.cart_delete_product').click(function(event){
        event.preventDefault();
        var item = this;
        var r = confirm('Ønsker du at slette dette produkt?');
        if (r == true) {
            jQuery(item).children('input:checkbox').prop('checked', 'checked');
            jQuery('#cart').submit();
        }
    });

    // Increase product quantity
    jQuery('a.cart_inc_qty').click(function(event){
        event.preventDefault();
        var quantity = jQuery(this).siblings('input').val() * 1;
        jQuery(this).siblings('input').val(quantity + 1);
        jQuery('#cart').submit();
    });

    // Decrease product quantity
    jQuery('a.cart_dec_qty').click(function(event){
        event.preventDefault();

        var quantity = jQuery(this).siblings('input').val() * 1;
        jQuery(this).siblings('input').val(quantity - 1);
        jQuery('#cart').submit();
        //jQuery('#cart').submit();
    });
</script>